#ifndef LCUNX_DEVICE_H
#define LCUNX_DEVICE_H

#include <Lucnx/types.h>

#define DF_WRITE 0b001
#define DF_READ  0b010
#define DF_IOCTL 0b100

typedef enum device_type_t
{
    DEV_NULL,
    DEV_CHAR,
    DEV_BLK,
    DEV_DEFAULT
}device_type_t;

typedef struct device_t
{
    char name[16];
    u8 flags;
    dev_t dev;
    void *ptr;
    device_type_t type;
    int (*ioctl) (void *ptr, char *buf, int count);
    int (*read)  (void *ptr, char *buf, int count);
    int (*write) (void *ptr, char *buf, int count);
}device_t;

dev_t device_install(
    char *name, void *ptr, void *read, void *write, void *ioctl, device_type_t type, u8 flags);
dev_t device_search(char *name);
int device_write(dev_t dev, void *ptr, char *buf, int count);
int device_read(dev_t dev, void *ptr, char *buf, int count);
int device_ioctl(dev_t dev, void *ptr, char *buf, int count);
void list_devices();

#endif